<?php 
@header('Content-type: text/html;charset=UTF-8');
require_once('check.php');
?>
<?php
	if($_POST["Submit"]) {
        $countyTypeId = str_replace(' ','',$_POST["countyTypeId"]);
        $countyTypeName = str_replace(' ','',$_POST["countyTypeName"]);
        $memo = str_replace(' ','',$_POST["memo"]);
        $sql = "select * from countytype where countyTypeId='$countyTypeId'";
        $rs = mysql_query($sql);
        if (mysql_num_rows($rs) == 1) {
            echo "<script language=javascript>alert('站点类型编号已存在！');history.back();</script>";
        } else {
            $sql = "insert into countytype (countyTypeId,countyTypeName,memo) values ($countyTypeId,'$countyTypeName','$memo')";
            mysql_query($sql);
            echo "<script language=javascript>alert('添加成功！');window.location='index.php?pageno=$pageno'</script>";
        }
    }
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>站点类型添加</title>
<link rel="stylesheet" href="../images/css.css" type="text/css" />
<script type="text/javascript">
 function check(){
	          var countyTypeId = document.getElementById("countyTypeId");
	          var countyTypeName = document.getElementById("countyTypeName");
	         if(trim(countyTypeId.value)==null || trim(countyTypeId.value)==""){
	             alert("请输入站点类型编号");
	             countyTypeId.focus();
	              return false;
	          }
	          if(trim(countyTypeName.value)==null || trim(countyTypeName.value)==""){
	             alert("请输入站点类型名称");
	             countyTypeName.focus();
	             return false;
	         }
	         
	         return true;
	     }
	     function trim(str){ //删除左右两端的空格
	     	return str.replace(/(^\s*)|(\s*$)/g, "");
	     }
</script>
</head>		 
<form id="form1" name="form1" method="post" action="" onsubmit="return check();">
  <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" bordercolor="#000000" bgcolor="#cccccc">
    <tr>
      <th colspan="2" bgcolor="#FFFFFF">添加站点类型</th>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" class="forumRowHighlight">类型编号:</td>
      <td bgcolor="#FFFFFF" class="forumRowHighlight"><input type="text" name="countyTypeId" id="countyTypeId" />*</td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" class="forumRowHighlight">类型名称:</td>
      <td bgcolor="#FFFFFF" class="forumRowHighlight"><input type="text" name="countyTypeName" id="countyTypeName"/>*</td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" class="forumRowHighlight">类型说明:</td>
      <td bgcolor="#FFFFFF" class="forumRowHighlight">
      	<textarea rows="5" cols="15" name="memo"></textarea>
      </td>
    </tr>
    <tr>
      <td colspan="2" align="center"><input name="Submit" type="submit" class="button" value="提交" />
      &nbsp;
      <input name="Submit2" type="reset" class="button" value="重置" /></td>
    </tr>
  </table> 
  </form>
</body>
</html>